﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using BaseEntities;
using BussinessLogic;
using DataAccess;
using System.Data;
using System.Data.SqlClient;

namespace UnitTest
{

    [TestClass]
    public class UnitTestUC1
    {
        SqlConnection conn = DBConnect.GetConnection();
        Card card = new Card();

        [TestMethod]
        public void ValidCard1()
        {
            conn.Open();
            string cardNo = "12562A434";
            card.CardNo = cardNo;
            bool expected = DataAccess.DataAccess.ExeStoredValidCard("sp_ValidCard", card);
            bool actual = BussinessLogic.ValidationLogic.ValidCard(card);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void ValidCard2()
        {
            conn.Open();
            string cardNo = "12562D434";
            card.CardNo = cardNo;
            bool expected = DataAccess.DataAccess.ExeStoredValidCard("sp_ValidCard", card);
            bool actual = BussinessLogic.ValidationLogic.ValidCard(card);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void ValidCard3()
        {
            conn.Open();
            string cardNo = "12562B434";
            card.CardNo = cardNo;
            bool expected = DataAccess.DataAccess.ExeStoredValidCard("sp_ValidCard", card);
            bool actual = BussinessLogic.ValidationLogic.ValidCard(card);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void ValidCard4()
        {
            conn.Open();
            string cardNo = "12562C434";
            card.CardNo = cardNo;
            bool expected = DataAccess.DataAccess.ExeStoredValidCard("sp_ValidCard", card);
            bool actual = BussinessLogic.ValidationLogic.ValidCard(card);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void ValidCard5()
        {
            conn.Open();
            string cardNo = "12562E434";
            card.CardNo = cardNo;
            bool expected = DataAccess.DataAccess.ExeStoredValidCard("sp_ValidCard", card);
            bool actual = BussinessLogic.ValidationLogic.ValidCard(card);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void ValidPIN1()
        {
            conn.Open();
            string cardPIN = "123456";
            string cardNo = "12562A434";
            card.PIN = cardPIN;
            card.CardNo = cardNo;
            bool expected = DataAccess.DataAccess.ExeStoredValidPIN("sp_ValidPIN", card);
            bool actual = ValidationLogic.ValidPIN(card);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void ValidPIN2()
        {
            conn.Open();
            string cardPIN = "123450";
            string cardNo = "12562A434";
            card.PIN = cardPIN;
            card.CardNo = cardNo;
            bool expected = DataAccess.DataAccess.ExeStoredValidPIN("sp_ValidPIN", card);
            bool actual = ValidationLogic.ValidPIN(card);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void ValidPIN3()
        {
            conn.Open();
            string cardPIN = "123056";
            string cardNo = "12562B434";
            card.PIN = cardPIN;
            card.CardNo = cardNo;
            bool expected = DataAccess.DataAccess.ExeStoredValidPIN("sp_ValidPIN", card);
            bool actual = ValidationLogic.ValidPIN(card);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void ValidPIN4()
        {
            conn.Open();
            string cardPIN = "123456";
            string cardNo = "12562D434";
            card.PIN = cardPIN;
            card.CardNo = cardNo;
            bool expected = DataAccess.DataAccess.ExeStoredValidPIN("sp_ValidPIN", card);
            bool actual = ValidationLogic.ValidPIN(card);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void ValidPIN5()
        {
            conn.Open();
            string cardPIN = "123456";
            string cardNo = "12562C434";
            card.PIN = cardPIN;
            card.CardNo = cardNo;
            bool expected = DataAccess.DataAccess.ExeStoredValidPIN("sp_ValidPIN", card);
            bool actual = ValidationLogic.ValidPIN(card);
            Assert.AreEqual(expected, actual);
        }
    }
}
